package gui;


import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class DefaultEnumableField extends DefaultField implements EnumableField {

    private Map<String, String> nameValue = new HashMap<String, String>();
    private Map<String, String> valueName = new HashMap<String, String>();

    public DefaultEnumableField(String fieldName, String fieldRepres) {
        super(fieldName, fieldRepres);

    }

    public String getNameByValue(String value) {
        String name = valueName.get(value);
        if (name == null) throw new IllegalArgumentException();
        return name;
    }

    public String getValueByName(String name) {
        String value = nameValue.get(name);
        if (value == null) throw new IllegalArgumentException();
        return value;
    }

    public Set<String> getValues() {
        return valueName.keySet();
    }


    public void addChoice(String name, String value) {
        nameValue.put(name, value);
        valueName.put(value, name);
    }

    public FieldProvider.Type getType() {
        return FieldProvider.Type.CHECK_BOX;
    }


}
